class Solution {
public:
    vector<int> check(int n) {
        vector<int> cnt(10, 0);
        while (n) {
            cnt[n % 10] += 1;
            n /= 10;
        }
        return cnt;
    }
    bool reorderedPowerOf2(int n) {
        vector<int> a = check(n);
        for (int i = 0; i < 31; i++) {
            if (check(1 << i) == a) 
                return true;
        }
        return false;
    }
};
